export default {
  data() {
    return {
      capturedVideo: '',
      videoDuration: 0
    }
  },
  
  onShow() {
    // 监听来自录像页面的结果
    uni.$on('faceCaptureResult', this.handleFaceCaptureResult);
  },
  
  onUnload() {
    uni.$off('faceCaptureResult', this.handleFaceCaptureResult);
  },
  
  methods: {
    openFaceCapture() {
      uni.navigateTo({
        url: '/pages/face-capture/face-capture'
      });
    },
    
    handleFaceCaptureResult(result) {
      if (result.success) {
        this.capturedVideo = result.videoPath;
        this.videoDuration = result.duration;
        
        uni.showToast({
          title: '录制成功',
          icon: 'success',
          duration: 2000
        });
      } else {
        uni.showToast({
          title: result.error || '录制失败',
          icon: 'none',
          duration: 2000
        });
      }
    },
    
    clearVideo() {
      this.capturedVideo = '';
      this.videoDuration = 0;
    }
  }
}